package com.sss.hloster06;

public class JavaExercise33 {

	public static void main(String[] args) {
		test33();
	}

	/**
	 * 打印出杨辉三角形（要求打印出10行如下图）
	 */
	private static void test33() {
		int i, j;
		int[][] a = new int[10][10];
		a[0][0] = 1;// 给第一行数组元素赋值
		for (i = 1; i < 10; i++) {
			a[i][0] = 1;
			a[i][i] = 1;
			for (j = 1; j < i; j++) {
				a[i][j] = a[i - 1][j] + a[i - 1][j - 1];
			}
		}
		System.out.println("杨辉三角输出如下：");
		// 定义一个二层循环输出数据
		for (i = 0; i < 10; i++) {
			for (int k = 0; k < 2 * (10 - i) - 1; k++) {
				System.out.print(" ");
			}
			for (j = 0; j <= i; j++) {
				System.out.print(" "+a[i][j] + " ");
			}
			System.out.println();
		}
	}

}
